]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Add AllView.addFolder() method
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 31 Jan 2013 14:32:02 +0000 (15:32 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 19 Feb 2013 23:18:56 +0000 (00:18 +0100)
Adjust AllView to be able to hold both apps and folders, and add an
addFolder() method to insert a folder.

https://bugzilla.gnome.org/show_bug.cgi?id=694192

js/ui/appDisplay.js

index e45c166bcbf1f59bd49a32b841178dcbc9f841bb..3aad5b022b77a07d45b5a62a5f3ca736dec264c6 100644 (file)
@@ -184,15 +184,29 @@ const AllView = new Lang.Class({
     },
 
     _getItemId: function(item) {
-        return item.get_id();
+        if (item instanceof Shell.App)
+            return item.get_id();
+        else if (item instanceof GMenu.TreeDirectory)
+            return item.get_menu_id();
+        else
+            return null;
     },
 
     _createItemIcon: function(item) {
-        return new AppIcon(item);
+        if (item instanceof Shell.App)
+            return new AppIcon(item);
+        else if (item instanceof GMenu.TreeDirectory)
+            return new FolderIcon(item, this);
+        else
+            return null;
     },
 
-    _compareItems: function(a, b) {
-        return a.compare_by_name(b);
+    _compareItems: function(itemA, itemB) {
+        // bit of a hack: rely on both ShellApp and GMenuTreeDirectory
+        // having a get_name() method
+        let nameA = GLib.utf8_collate_key(itemA.get_name(), -1);
+        let nameB = GLib.utf8_collate_key(itemB.get_name(), -1);
+        return (nameA > nameB) ? 1 : (nameA < nameB ? -1 : 0);
     },
 
     addApp: function(app) {
@@ -202,6 +216,13 @@ const AllView = new Lang.Class({
                                   Lang.bind(this, this._ensureIconVisible));
     },
 
+    addFolder: function(dir) {
+        let folderIcon = this._addItem(dir);
+        if (folderIcon)
+            folderIcon.actor.connect('key-focus-in',
+                                     Lang.bind(this, this._ensureIconVisible));
+    },
+
     addFolderPopup: function(popup) {
         this._stack.add_actor(popup.actor);
         popup.connect('open-state-changed', Lang.bind(this,